<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<sc-export-button :auth="'stock.export'" :apiObj="apiObj" :search="search"></sc-export-button>
			</div>
			<div class="right-panel">
				<div class="right-panel-search">
					<el-input v-model="search.goods_name" placeholder="产品型号" clearable @keyup.enter="upsearch"></el-input>
					<el-input v-model="search.goods_code" placeholder="产品编号" clearable @keyup.enter="upsearch"></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
                    <el-button type="primary" icon="el-icon-refresh" @click="refresh"></el-button>
				</div>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" show-summary remoteSummary row-key="id" @sort-change="onSortChange" stripe remoteSort>
				<el-table-column type="selection" width="50"></el-table-column>
				<el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
                <el-table-column label="品类" prop="goods.cate.cate_name" align="center"></el-table-column>
				<el-table-column label="产品型号" prop="goods.goods_name" align="center"></el-table-column>
				<el-table-column label="产品编码" prop="goods.goods_code" align="center"></el-table-column>
				<el-table-column label="产品单位" prop="goods.unit.unit_name" align="center"></el-table-column>
				<el-table-column label="仓库" prop="ware_name" align="center"></el-table-column>
				<el-table-column label="建议备货数量" prop="stock_up_plan" align="center"></el-table-column>
				<el-table-column label="当前库存数量" prop="stock_now_num" align="center"></el-table-column>
				<el-table-column label="上月销售数量" prop="last_month_sale_num" align="center"></el-table-column>
			</scTable>
		</el-main>
	</el-container>

	<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" @closed="dialog.save = false"></save-dialog>

</template>

<script>
import saveDialog from './save'

export default {
	name: '查询1',
	components: {
		saveDialog
	},
	data() {
		return {
			dialog: {
				save: false
			},
			apiObj: this.$API.ware.readShop,
			selection: [],
			search: {
                goods_name: null,
                goods_code: null,
			},
		}
	},
	mounted() {
	},
	methods: {
		//表格选择后回调事件
		selectionChange(selection) {
			this.selection = selection;
		},
		//搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
        refresh() {
			for (const key in this.search) {
				this.search[key] = null;
			}
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style></style>
